{if count($score->scores)>0}
  <h1>Classements</h1>
  <div>
    <table>
    <tr>
        <th>&nbsp;</th>
        <th>Equipe</th>
        <th><abbr title="Points">Pts.</abbr></th>
        <th><abbr title="Matchs joués">MJ</abbr></th>
        <th><abbr title="Matchs gagnés">MG</abbr></th>
        <th><abbr title="Egalités">&equals;</abbr></th>
        <th><abbr title="Points pour">PP</abbr></th>
        <th><abbr title="Points contre">PC</abbr></th>
        <th><abbr title="Différence">Diff.</abbr></th>
    </tr>
    
    {assign var=pos   value="1"}
    {assign var=warn  value=false}
    {assign var=old_pts value=0}
    {foreach from=$score->scores key=key item=resultat}
    <tr>
      <td>
      {if $old_pts!=$resultat.points}
          {$pos}
      {else}
          -
          {assign var=warn  value=true}
      {/if}
      {assign var=pos value=$pos+1}
      {assign var=old_pts value=$resultat.points}
      </td>
      <td>{equipe_link id=$resultat.equipe_id truncate=30}</td>
      <td>{$resultat.points}</td>
      <td>{$resultat.joues}</td>
      <td>{$resultat.gagnes}</td>
      <td>{$resultat.egalites}</td>
      <td>{$resultat.pp}</td>
      <td>{$resultat.pc}</td>
      <td>{$resultat.diff}</td>
    </tr>
    {/foreach}

    {if $warn}
    <tr>
      <th colspan="9">
        <a href="#" class="warn-link">Besoin d'explications?</a>
        <div class="warn-classement">
          <h2>En cas d'égalité entre deux équipes la règle suivante s'applique pour determiner la meilleure des deux :</h2>
          <ol>
            <li>Le plus grand nombre de victoires sur l’ensemble des matches.
            <li>La plus grande différence entre points marqués et points concédés sur l’ensemble des matches (goal-average).
            <li>La différence des points de la confrontation directe.</li>
            <li>L'ordre alphabétique</li>
          </ol>
        </div>
      </th>
    </tr>
    {/if}
    </table>
    <h4>Phases finales {if !$score->demiesOk}<u>potentielles</u>{/if}</h4>
    <div class="demies">
      <table>
          <tbody>
              <tr>
                  <th class="col-1">&nbsp;</th>
                  <th class="col-2">Date</th>
                  <th class="col-3">Equipes</th>
                  {if $score->demiesOk}<th class="col-4">Scores</th>{/if}
              </tr>
              <tr>
                {assign var=demie value=$score->demies[0]}
                  <td class="col-1">Demi-finale A</td>
                  <td class="col-2">{$demie.match_date|date_format:"%A %d %B"}</td>
                  {if $score->demiesOk}
                  <td class="col-3">{score equipeA=$demie.match_equipe_A equipeB=$demie.match_equipe_B scoreA=$demie.match_score_A scoreB=$demie.match_score_B truncate=30}</td>
                  <td class="col-4">{score match_id=$demie.match_id scoreA=$demie.match_score_A scoreB=$demie.match_score_B}</td>
                  {else}
                    <td class="col-3">{equipe_link id=$demie.match_equipe_A} vs {equipe_link id=$demie.match_equipe_B}</td>
                  {/if}
              </tr>
              <tr>
                {assign var=demie value=$score->demies[1]}
                  <td class="col-1">Demi-finale B</td>
                  <td class="col-2">{$demie.match_date|date_format:"%A %d %B"}</td>
                  {if $score->demiesOk}
                  <td class="col-3">{score equipeA=$demie.match_equipe_A equipeB=$demie.match_equipe_B scoreA=$demie.match_score_A scoreB=$demie.match_score_B truncate=30}</td>
                  <td class="col-4">{score match_id=$demie.match_id scoreA=$demie.match_score_A scoreB=$demie.match_score_B}</td>
                  {else}
                    <td class="col-3">{equipe_link id=$demie.match_equipe_A} vs {equipe_link id=$demie.match_equipe_B}</td>
                  {/if}
              </tr>
              {assign var=demie value=$score->demies[2]}
              <tr>
                  <td class="col-1">Finale</td>
                  <td class="col-2">{$demie.match_date|date_format:"%A %d %B"}</td>
                  {if $demie.match_equipe_A >0 || $demie.match_equipe_B>0}
                  <td class="col-3">{score equipeA=$demie.match_equipe_A equipeB=$demie.match_equipe_B scoreA=$demie.match_score_A scoreB=$demie.match_score_B truncate=30}</td>
                  <td class="col-4">{score match_id=$demie.match_id scoreA=$demie.match_score_A scoreB=$demie.match_score_B}</td>
                  {else}
                  <td class="col-3">&nbsp;</td>
                  {/if}
              </tr>
          </tbody>
      </table>
    </div>
  </div>
{else}
  <h1>Equipes</h1>
  <div>
    <ul>
    {foreach from=$score->equipes item=equipe}
      <li>{equipe_link id=$equipe.equipe_id}</li>
    {foreachelse}
      <li>Ah ca sent le début de saison, revenez plus tard</li>
    {/foreach}
    </ul>
  </div>
{/if}


